# enumerate
## 对于集合、列表、元组，能够获取具体元素的索引
animals = ("dog","cat","lion")
print(animals)
for indexAnimal in enumerate(animals):
    print(indexAnimal)
    index,animal = indexAnimal
    print(index,animal)

# break、continue、pass
## break 中断循环
## continue 跳过后面的语句，进入循环下一步
## pass 无意义，做一个填充
print("break、continue、pass")
for i in animals:
    pass
    # pass
    # print(i)
    # if i == "cat":
    #     pass
    #
    # print(" ---- ")

## split 让字符串以括号中的元素为分割点，做切分成列表
context= "The integration of Encoded Archival Description (EAD) with item-level " \
         "metadata schemas like Dublin Core and MODS aims to enhance access and discoverability of " \
         "digital archival resources. This combined metadata schema helps make archival materials both" \
         " easy to find and contextualized within their broader collection framework. It effectively " \
         "addresses the challenge of providing sufficient detail at the item level while also retaining " \
         "the broader context necessary for archival materials."
context = context.lower().split(" ")
print(context)
## 获取不同单词的出现次数  {word:count}
wordCount = dict()
for word in context:
    # print(wordCount[word])
    if word not in wordCount:
        # 初始化频次
        wordCount[word] = 1
    else:
        # 频次加1
        wordCount[word] = wordCount[word] + 1
print(wordCount)

wordCount = dict()
# try except
# 如果try下代码块中发生了异常，执行except下面的代码来处理异常
for word in context:
    ## 处理异常
    try:
        wordCount[word] = wordCount[word] + 1
    # except KeyError:
    #     wordCount[word] = 1
    except Exception:
        wordCount[word] = 1

print(wordCount)
#789